import 'package:flustars/flustars.dart';
import 'package:get/get.dart';

import 'package:zrjz/comm/constants/app_constant.dart';
import 'package:zrjz/comm/http/http_result.dart';
import 'package:zrjz/comm/utils/log_utils.dart';
import 'package:zrjz/globalService/user_service.dart';

class NotificationEnableController extends GetxController {


  bool isSelected = true;

  @override
  void onReady() {
    super.onReady();
    isSelected = SpUtil.getBool(AppConstant.storageNotificationEnable, defValue: true) ?? true;
    update();
  }

  void changed(bool checked) {
    isSelected = checked;
    SpUtil.putBool(AppConstant.storageNotificationEnable, checked);
    update();

    _resetRegistrationIdId(checked ? UserService.to.getRegistrationId : "null");
  }

  /// 调用接口重新设置 registrationId
  void _resetRegistrationIdId(String registrationId) async {
    // if (UserService.to.isLogin) {
    //   //获取到数据
    //   HttpResult result = await mainRepository.resetRegistrationId(registrationId);
    //
    //   //处理数据
    //   if (result.isSuccess) {
    //     Log.d("MainController 重置 registrationId 成功");
    //   } else {
    //     Log.d("MainController 重置 registrationId 失败：${result.errorMsg}");
    //   }
    // }
  }
}
